package com.srd.phone.utils;

import com.srd.phone.bean.TabMine;
import com.srd.phone.bean.UserInfo;

/**
 */
public class UserUtils{

    /**
     * 删除用户信息
     */
    public static void deleteUserInfo(){
        PreferenceUtils.getInstance().cleatData();
    }

    /**
     * 保存用户信息
     */
    public static void saveUserInfo(UserInfo info) {
        PreferenceUtils.getInstance().putData("UserInfo.ticket", CommonUtils.encode(info.ticket));
        PreferenceUtils.getInstance().putData("UserInfo.user", info.userName);
        PreferenceUtils.getInstance().putData("UserInfo.pwd", CommonUtils.encode(info.pwd));
        PreferenceUtils.getInstance().putData("UserInfo.token", info.token);

        PreferenceUtils.getInstance().putData("user.uid", info.uid);
        PreferenceUtils.getInstance().putData("user.src", info.src);
        PreferenceUtils.getInstance().putData("info.email", info.email);
        PreferenceUtils.getInstance().putData("user.available", info.available + "");
        PreferenceUtils.getInstance().putData("user.frozenfund", info.frozenfund + "");
        PreferenceUtils.getInstance().putData("user.penmoney", info.penmoney + "");
        PreferenceUtils.getInstance().putData("user.scRecord", info.scRecord + "");
        PreferenceUtils.getInstance().putData("user.sinves", info.sinves + "");
        PreferenceUtils.getInstance().putData("user.sprofit", info.sprofit + "");
        PreferenceUtils.getInstance().putData("user.sumreco", info.sumreco + "");
        PreferenceUtils.getInstance().putData("user.total", info.total + "");
        PreferenceUtils.getInstance().putData("user.order", info.order);
    }


    /**
     * 获取用户信息
     */
    public static UserInfo getUserInfo() {
        UserInfo userInfo = new UserInfo();
        userInfo.ticket = CommonUtils.decode(PreferenceUtils.getInstance().getData("UserInfo.ticket", ""));
        userInfo.userName = PreferenceUtils.getInstance().getData("UserInfo.user", "---");
        userInfo.pwd = CommonUtils.decode(PreferenceUtils.getInstance().getData("UserInfo.pwd", ""));
        userInfo.token = PreferenceUtils.getInstance().getData("UserInfo.token", "");

        userInfo.uid = PreferenceUtils.getInstance().getData("user.uid", "");
        userInfo.src = PreferenceUtils.getInstance().getData("user.src", "");
        userInfo.email = PreferenceUtils.getInstance().getData("info.email", "");
        userInfo.available = PreferenceUtils.getInstance().getData("user.available", "0");
        userInfo.frozenfund = PreferenceUtils.getInstance().getData("user.frozenfund", "0");
        userInfo.penmoney = PreferenceUtils.getInstance().getData("user.penmoney", "0");
        userInfo.scRecord = PreferenceUtils.getInstance().getData("user.scRecord", "0");
        userInfo.sinves =PreferenceUtils.getInstance().getData("user.sinves", "0");
        userInfo.sprofit = PreferenceUtils.getInstance().getData("user.sprofit", "0");
        userInfo.sumreco = PreferenceUtils.getInstance().getData("user.sumreco", "0");
        userInfo.total = PreferenceUtils.getInstance().getData("user.total", "0");
        userInfo.order = PreferenceUtils.getInstance().getData("user.order", "0");
        return userInfo;
    }


    /**
     * 账户总览
     * */
    public static void saveOverViews(TabMine info) {

        PreferenceUtils.getInstance().putData("user.available", info.available + "");
        PreferenceUtils.getInstance().putData("user.frozenfund", info.frozenfund + "");
        PreferenceUtils.getInstance().putData("user.penmoney", info.penmoney + "");
        PreferenceUtils.getInstance().putData("user.scRecord", info.scRecord + "");
        PreferenceUtils.getInstance().putData("user.sinves", info.sinves + "");
        PreferenceUtils.getInstance().putData("user.sprofit", info.sprofit + "");
        PreferenceUtils.getInstance().putData("user.sumreco", info.sumreco + "");
        PreferenceUtils.getInstance().putData("user.total", info.total + "");
        PreferenceUtils.getInstance().putData("user.order", info.order);

    }

    /**
     * 获取登录状态  true： 登录    false ： 未登录
     * */
    public static boolean getLoginStatus(){
        return PreferenceUtils.getInstance().getData(Constants.LOGIN_STATUS, false);
    }

}
